import request from './request'
import type { SaleRecord } from '@/types'

export const getSales = (params?: any) => {
  return request({
    url: '/sale/page',
    method: 'post',
    data: params
  })
}

export const getSale = (id: number) => {
  return request({
    url: `/sale/${id}`,
    method: 'get'
  })
}

export const createSale = (data: Partial<SaleRecord>) => {
  return request({
    url: '/sale',
    method: 'post',
    data
  })
}

export const updateSale = (id: number, data: Partial<SaleRecord>) => {
  return request({
    url: `/sale/${id}`,
    method: 'put',
    data
  })
}

export const deleteSale = (id: number) => {
  return request({
    url: `/sale/${id}`,
    method: 'delete'
  })
}